AMD/IOMMU: fix off-by-one in amd_iommu_get_paging_mode() callers
authorJan Beulich <jbeulich@suse.com>
Thu, 9 Apr 2020 08:11:50 +0000 (10:11 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 9 Apr 2020 08:11:50 +0000 (10:11 +0200)
commit696d142276e277264a9c6fcdd4f00edc8a6ce292
tree074d74161606b37e07a2bbb6dbcd780c7bc89863
parent6bc54c0696c0f6f639598363d284c7188a9e20ae
AMD/IOMMU: fix off-by-one in amd_iommu_get_paging_mode() callers

amd_iommu_get_paging_mode() expects a count, not a "maximum possible"
value. Prior to b4f042236ae0 dropping the reference, the use of our mis-
named "max_page" in amd_iommu_domain_init() may have lead to such a
misunderstanding. In an attempt to avoid such confusion in the future,
rename the function's parameter and - while at it - convert it to an
inline function.

Also replace a literal 4 by an expression tying it to a wider use
constant, just like amd_iommu_quarantine_init() does.

Fixes: ea38867831da ("x86 / iommu: set up a scratch page in the quarantine domain")
Fixes: b4f042236ae0 ("AMD/IOMMU: Cease using a dynamic height for the IOMMU pagetables")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: b75b3c62fe4afe381c6f74a07f614c0b39fe2f5d
master date: 2020-03-16 11:24:29 +0100
xen/drivers/passthrough/amd/iommu_map.c
xen/drivers/passthrough/amd/pci_amd_iommu.c
xen/include/asm-x86/hvm/svm/amd-iommu-proto.h